package com.simple.admin.controller.common;

import com.simple.framework.core.controller.BaseController;
import com.simple.framework.core.domain.R;
import com.simple.framework.core.domain.entity.SysFile;
import com.simple.system.annotation.SystemLog;
import com.simple.system.enums.BusinessType;
import com.simple.system.service.SysFileService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description 文件(SysFile)表实 控制类
 * @Author xiaoke
 * @Date 2024/8/10 18:00
 * @Version 1.0
 */
@RestController
@RequestMapping("/common/file")
public class SysFileController extends BaseController {

    private final SysFileService sysFileService;

    public SysFileController(SysFileService sysFileService) {
        this.sysFileService = sysFileService;
    }

    /**
     * 文件上传
     *
     * @param file 文件
     * @return 文件url
     */
    @SystemLog(title = "上传文件",businessType = BusinessType.OTHER)
    @PostMapping("/upload")
    public R<SysFile> uploadFile(@RequestParam("file") MultipartFile file) {
        return success(sysFileService.uploadFile(file));
    }


}
